package com.ssy.lingxi.purchase.handler.notify;

import com.rabbitmq.client.Channel;
import com.ssy.lingxi.component.rabbitMQ.constants.MessageConstants;
import com.ssy.lingxi.purchase.service.tender.IInviteTenderService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 提交资格预审时间开始，外部状态改成待提交资格预审-消息队列监听类
 * @author jw.chen
 * @version 2.0.0
 * @date 2020/10/22
 */
@Component
@RabbitListener(queues = MessageConstants.purchase_not_submit_qualifications_check_delay_queue)
public class NotSubmitQualificationsCheckMessageHandler {

    @Autowired
    private IInviteTenderService inviteTenderService;

    private final Logger log = LoggerFactory.getLogger(this.getClass());

    @RabbitHandler
    public void handler(Channel channel, Message message, Long inviteTenderId){
        try{
            log.info("收到通知，提交资格预审时间开始，外部状态改成待提交资格预审，投标id: "+inviteTenderId);
            inviteTenderService.notSubmitQualificationsCheck(inviteTenderId);
            //手动确认
            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
        }catch (Exception e){
            e.printStackTrace();
        }
    }
}
